﻿<%@ Page Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="MaterialList.aspx.cs"
    Inherits="Inventory_MaterialList" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="phMain" runat="Server">
    <fieldset style="margin: 10px 10px 10px 10px; padding: 5px 5px 5px 5px;">
        <legend>搜索条件</legend>物料编号：<asp:TextBox ID="txtMaterialID" runat="server"></asp:TextBox>&nbsp;
        物料名称：<asp:TextBox ID="txtMaterialName" runat="server"></asp:TextBox><font style="color: Red">支持模糊查询</font>
        状态：
        <asp:DropDownList ID="ddlStatus" runat="server" DataSourceID="ObjectDataSource1">
        </asp:DropDownList>
        适合品牌：
        <asp:DropDownList ID="ddlBrand" runat="server">
        </asp:DropDownList>
        适合地区：
        <asp:DropDownList ID="ddlRegion" runat="server">
        </asp:DropDownList>
        <asp:Button ID="btnQuery" Text="查询" runat="server" OnClick="btnQuery_Click" />
    </fieldset>
    <fieldset style="margin: 10px 10px 10px 10px; padding: 5px 5px 5px 5px;">
        <asp:GridView ID="GridView1" runat="server" BorderWidth="1px" EmptyDataText="找不到批配的数据"
            HorizontalAlign="Center" Width="100%" AutoGenerateColumns="False" AllowPaging="True"
            DataSourceID="ObjectDataSource2" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="MaterialID" OnPageIndexChanged="GridView1_PageIndexChanged" OnRowCommand="GridView1_RowCommand" PageSize="20">
            <EmptyDataRowStyle BackColor="#0000C0" Font-Bold="True" Font-Size="12pt" />
            <HeaderStyle BackColor="Gray" />
            <AlternatingRowStyle BackColor="#E0E0E0" />
            <EditRowStyle ForeColor="White" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" SelectText="设置属性" />
                <asp:BoundField DataField="MaterialID" HeaderText="物料编号" SortExpression="MaterialID" />
                <asp:BoundField DataField="MaterialName" HeaderText="物料名称" SortExpression="MaterialName" />
                <asp:BoundField DataField="Spec" HeaderText="规格" SortExpression="Spec" />
                <asp:BoundField DataField="OrderUnit" HeaderText="订货单位" SortExpression="OrderUnit" />
                <asp:BoundField DataField="Order_Cycle" HeaderText="订货周期" SortExpression="Order_Cycle" NullDisplayText="未知" />
                <asp:BoundField DataField="Stocktaking_Cycle" HeaderText="盘存周期" SortExpression="Stocktaking_Cycle" NullDisplayText="未知" />
                <asp:BoundField DataField="DeliveryType" HeaderText="送货方式" SortExpression="DeliveryType" NullDisplayText="未知" />
                <asp:BoundField DataField="LogisticCategoryFullName" HeaderText="Logistic分类"
                    SortExpression="LogisticCategoryFullName" />
                <asp:BoundField DataField="LogisticStatus" HeaderText="Logistic状态" SortExpression="LogisticStatus" />
                <asp:BoundField DataField="Status" HeaderText="SMS状态" SortExpression="Status" />
                <asp:TemplateField HeaderText="操作">
                <ItemTemplate>
                    <asp:LinkButton ID="lbtnChangeStatus" runat="server" Text='<%# Eval("Status").ToString()=="禁用"?"设为启用":"设为禁用" %>' CommandName="ChangeStatus" CommandArgument='<%#Eval("MaterialID") %>'></asp:LinkButton>
                </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <SelectedRowStyle BackColor="Blue" ForeColor="White" />
        </asp:GridView>
    </fieldset>
    <fieldset style="margin: 10px 10px 10px 10px; padding: 5px 5px 5px 5px; height: auto;
        border: 0px">
        <asp:Panel ID="Panel1" runat="server" GroupingText="设置属性" Width="100%">
            <br />
            <table width="100%">
                <tr>
                    <td style="background: #E0E0E0">
                        <asp:CheckBox ID="chkBrandAll"  runat="server" AutoPostBack="True" OnCheckedChanged="chkBrandAll_CheckedChanged" />&nbsp;适合品牌</td>
                </tr>
                <tr>
                    <td style="background: #ffffee">
                        <asp:CheckBoxList ID="chkBrandList" runat="server" DataSourceID="ods_Brand" DataTextField="BrandName"
                            DataValueField="BrandID" RepeatColumns="6" RepeatDirection="Horizontal">
                        </asp:CheckBoxList></td>
                </tr>
                <tr>
                    <td style="background: #E0E0E0">
                        <asp:CheckBox ID="chkRegionAll"  runat="server" AutoPostBack="True" OnCheckedChanged="chkRegionAll_CheckedChanged" />&nbsp;适合地区</td>
                </tr>
                <tr>
                    <td style="background: #ffffee">
                        <asp:CheckBoxList ID="chkRegionList" runat="server" DataSourceID="ods_Region" DataTextField="RegionName"
                            DataValueField="RegionID" RepeatColumns="6" RepeatDirection="Horizontal">
                        </asp:CheckBoxList></td>
                </tr>
                <tr>
                    <td style="background: #E0E0E0">
                        订货属性</td>
                </tr>
                <tr>
                    <td style="background: #ffffee">
                        <asp:Label ID="Label1" runat="server" Text="最小订量："></asp:Label>
                        <asp:TextBox ID="txtMinOrderValue" runat="server"></asp:TextBox>
                        &nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                            ControlToValidate="txtMinOrderValue" Display="Dynamic" ErrorMessage="*必须为数字"
                            SetFocusOnError="True" ValidationExpression="\d"></asp:RegularExpressionValidator>
                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtMaxOrderValue"
                            ControlToValidate="txtMinOrderValue" Display="Dynamic" ErrorMessage="*必须小于等于最大订量"
                            Operator="LessThanEqual" SetFocusOnError="True" Type="Double"></asp:CompareValidator>
                        <br />
                        <asp:Label ID="Label2" runat="server" Text="最大订量："></asp:Label>
                        <asp:TextBox ID="txtMaxOrderValue" runat="server"></asp:TextBox>
                        &nbsp;
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtMaxOrderValue"
                            Display="Dynamic" ErrorMessage="*必须为数字" ValidationExpression="\d"></asp:RegularExpressionValidator>
                        <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="txtMinOrderValue"
                            ControlToValidate="txtMaxOrderValue" Display="Dynamic" ErrorMessage="*必须大于等于最大订量"
                            Operator="GreaterThanEqual" SetFocusOnError="True" Type="Double"></asp:CompareValidator></td>
                </tr>
                <tr>
                    <td style="background: #E0E0E0">
                        订货／盘存周期</td>
                </tr>
                <tr>
                    <td style="background: #ffffee">
                        <asp:Label ID="Label3" runat="server" Text="订货周期："></asp:Label>
                        <asp:DropDownList ID="ddlOrderCycle" runat="server" DataSourceID="odsOrderCycle">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlOrderCycle"
                            Display="Dynamic" ErrorMessage="订货周期不能为空" SetFocusOnError="True"></asp:RequiredFieldValidator>
                        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
                            <asp:View ID="View1" runat="server">
                                <asp:LinkButton ID="lbtnNewOrderCycle" runat="server" OnClick="lbtnNewOrderCycle_Click"
                                    CommandName="NextView" CausesValidation="False">新建订货周期......</asp:LinkButton>
                            </asp:View>
                            <asp:View ID="View2" runat="server">
                                名称：
                                <asp:TextBox ID="txtNewOrderCycle" runat="server"></asp:TextBox>
                                &nbsp;
                                <asp:LinkButton ID="lbtnSaveOrderCycle" runat="server" OnClick="lbtnSaveOrderCycle_Click" CausesValidation="False">保存订货周期</asp:LinkButton>｜
                                <asp:LinkButton ID="lbtnCancel" runat="server" CommandName="PrevView" CausesValidation="False">取消</asp:LinkButton>
                            </asp:View>
                        </asp:MultiView>
                        <br />
                        <asp:Label ID="Label4" runat="server" Text="盘存周期："></asp:Label>
                        <asp:DropDownList ID="ddlStocktakingCycle" runat="server" DataSourceID="odsStocktakingCycle">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlStocktakingCycle"
                            Display="Dynamic" ErrorMessage="盘存周期不能为空" SetFocusOnError="True"></asp:RequiredFieldValidator>
                        <asp:MultiView ID="MultiView2" runat="server" ActiveViewIndex="0">
                            <asp:View ID="View3" runat="server">
                                <asp:LinkButton ID="lbtnNewStocktakingCycle" runat="server" CommandName="NextView"
                                    OnClick="lbtnNewStocktakingCycle_Click" CausesValidation="False">新建盘存周期......</asp:LinkButton>
                            </asp:View>
                            <asp:View ID="View4" runat="server">
                                名称：
                                <asp:TextBox ID="txtNewStocktakingCycle" runat="server"></asp:TextBox>
                                <asp:LinkButton ID="lbtnSaveStocktakingCycle" runat="server" OnClick="lbtnSaveStocktakingCycle_Click" CausesValidation="False">保存盘存周期</asp:LinkButton>｜
                                <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PrevView" CausesValidation="False">取消</asp:LinkButton>
                            </asp:View>
                        </asp:MultiView></td>
                </tr>
                <tr>
                    <td style="background: #E0E0E0">
                        配送方式</td>
                </tr>
                <tr>
                    <td style="background: #ffffee">
                        配送方式：<asp:DropDownList ID="ddlDeliveryType" runat="server" DataSourceID="odsDeliveryType">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlDeliveryType"
                            Display="Dynamic" ErrorMessage="配送方式不能为空" SetFocusOnError="True"></asp:RequiredFieldValidator>
                        <asp:MultiView ID="MultiView3" runat="server" ActiveViewIndex="0">
                            <asp:View ID="View5" runat="server">
                                <asp:LinkButton ID="lbtnDeliveryType" runat="server" CommandName="NextView" OnClick="lbtnDeliveryType_Click" CausesValidation="False">新建配送方式......</asp:LinkButton>
                            </asp:View>
                            <asp:View ID="View6" runat="server">
                                名称：
                                <asp:TextBox ID="txtNewDeliveryType" runat="server"></asp:TextBox>
                                <asp:LinkButton ID="lbtnSaveDeliveryType" runat="server" OnClick="lbtnSaveDeliveryType_Click" CausesValidation="False">保存配送方式</asp:LinkButton>｜
                                <asp:LinkButton ID="LinkButton4" runat="server" CommandName="PrevView" CausesValidation="False">取消</asp:LinkButton>
                            </asp:View>
                        </asp:MultiView>
                    </td>
                </tr>
                                <tr>
                    <td style="background: #E0E0E0">
                        备注</td>
                </tr>
                <tr>
                    <td style="background: #ffffee" valign="top">
                        <asp:TextBox ID="txtDescription" runat="server" Columns=5 TextMode="MultiLine" Width="725px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td style="height: 1px; background: #000000">
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="保存设置" Width="72px" />
                        <asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label></td>
                </tr>
            </table>
        </asp:Panel>
    </fieldset>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getDistinctMaterialStatus"
        TypeName="Inventory"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="getMaterialsByCondition"
        TypeName="Inventory">
        <SelectParameters>
            <asp:ControlParameter ControlID="txtMaterialID" Name="materialID" PropertyName="Text"
                Type="String" />
            <asp:ControlParameter ControlID="txtMaterialName" Name="materialName" PropertyName="Text"
                Type="String" />
            <asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="ddlBrand" Name="brand" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="ddlRegion" Name="region" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ods_Region" runat="server" SelectMethod="GetRegionsExceptHQ"
        TypeName="BaseInfoDB"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsOrderCycle" runat="server" SelectMethod="getDistinctMaterialOrderCycle"
        TypeName="Inventory"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ods_Brand" runat="server" SelectMethod="GetBrands" TypeName="BaseInfoDB">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsDeliveryType" runat="server" SelectMethod="getDistinctMaterialDeliveryType"
        TypeName="Inventory"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsStocktakingCycle" runat="server" SelectMethod="getDistinctMaterialStocktakingCycle"
        TypeName="Inventory"></asp:ObjectDataSource>
</asp:Content>
